#!/usr/bin/python
# -*- coding: utf-8 -*-

'''
Introduction to Programming in Java - An Interdisciplinary Approach

All book programs ported to Python by
Scott C. King (revisionx at {gee}ma1l <dot> c0m).

All program examples pass Pylint with a perfect 10.00 score.
Pylint:  http://www.pylint.org/


# Program 1.2.5 - Casting to get a random integer

Syntax:
python randint.py 100


Notes:
sys is a required import here in order to use command line arguments.
https://docs.python.org/2/tutorial/stdlib.html

int(sys.argv[1]) == Integer.parseInt(args[1])

random is a required import as a substitute for Java's Math.random()
https://docs.python.org/2/library/random.html

'''

import sys
import random

def main():
    '''  Print random number between 0 and user-defined range. '''

    arg = int(sys.argv[1])
    random_num = random.random() # Returns floating point in range [0.0, 1.0)
    print int(arg * random_num)

    print
    # Alternate using random's randint method
    print random.randint(0, arg)

if __name__ == '__main__':
    main()




